(* FileIO     Simple IO with more than one file         Moe 18.01.84
   ======        =================================
This module provides procedures which are similar to those of InOut,
except that they can be used with more than one file even with the
console).
------------------------------------------------------------------------*)
DEFINITION MODULE FileIO;
 
FROM FileSystem IMPORT File;
FROM SYSTEM     IMPORT WORD;

(*EXPORT QUALIFIED
  DEL, EF, EOL, ESC,
  con, Done, termCH,
  Read, Write, WriteCard, WriteLn, WriteString,
  WriteText, WriteWord;                      (*25.11.,D,Dob*)   *)

CONST
  DEL = 177C;
  EF  =   4C;
  EOL =  36C;
  ESC =  33C;

VAR
  con:    File;            (*console file*)
  Done:   BOOLEAN;         (*TRUE if an operation sucessful*)
  termCH: CHAR;            (*first character after input text*)

PROCEDURE Read(VAR f:File; VAR ch:CHAR);
(* Reads a character ch from the  file f (no echo on the console)*)

PROCEDURE Write(VAR f:File; ch:CHAR);
(* Writes a character ch to the file f*)

PROCEDURE ReadCard(VAR f:File; VAR val:CARDINAL);

PROCEDURE WriteCard(VAR f:File; nr:CARDINAL; w:CARDINAL);
(* Writes a cardinal nr with width w to the file f. If the actual
   width of nr is bigger than w, w is expanded*)

PROCEDURE ReadInt(VAR f:File; VAR val:INTEGER);   

PROCEDURE WriteInt(VAR f:File; i:INTEGER; w:CARDINAL);

PROCEDURE ReadLn(VAR f:File);
(* Skips to the next line on the file f*)

PROCEDURE WriteLn(VAR f:File);
(* Skips to the next line on the file f*)

PROCEDURE ReadString(VAR f:File; VAR s:ARRAY OF CHAR);

PROCEDURE WriteString(VAR f:File; s:ARRAY OF CHAR);
(* Write a string s to the file f. An occurrence of the character "$"
   in s causes a line feed*)

PROCEDURE WriteText(VAR f:File; t:ARRAY OF CHAR; l:CARDINAL);
(* Writes a text t with length l to the file f*)

PROCEDURE ReadWord(VAR f:File; VAR w:CARDINAL);  

PROCEDURE WriteWord(VAR f:File; w:CARDINAL);
(* Writes a word w without conversion to the file f*)

END FileIO.
